package b3.widget.guide
{
	import b3.model.*;
	import b3.net.*;
	import b3.util.*;
	import b3.widget.basic.*;
	import b3.widget.mail.ObjectSlot;
	
	import flash.display.*;
	import flash.events.*;
	import flash.filters.*;
	import flash.text.*;

	public class LogonAwardDialog extends BasicWidget
	{
		private var message:TextField;
		private var closeButton:BasicButton;
		
		public function LogonAwardDialog(day:int,awards:Array)
		{
			super();
			this.anchor = ANCHOR_MIDDLE_MIDDLE;
			this.effect = EFFECT_EXPAND;
			var Bgr:Class = ResourceHelper.getInstance().getClassByName("MessageBoxBgr");
			var bgr:Sprite = new Bgr();
			bgr.scaleX = 1.2;
			bgr.scaleY = bgr.scaleX;
			bgr.mouseChildren = false;
			addChild(bgr);
			
			var NpcMajor:Class = ResourceHelper.getInstance().getClassByName("NpcMajor1");
			var major:Sprite = new NpcMajor();
			major.width = 140;
			major.scaleY = major.scaleX;
			major.x = 350;
			major.y = 370;
			major.mouseChildren = false;
			addChild(major);
			var maskSprite:Sprite = new Sprite();
			maskSprite.graphics.beginFill(0x000000);
			maskSprite.graphics.drawRect(0, 0, 150, 360);
			maskSprite.graphics.endFill();
			addChild(maskSprite);
			maskSprite.x = 350;
			major.mask = maskSprite;
			//标题
			var titleField:TextField = new TextField();
			titleField.selectable = false;
        	titleField.autoSize = TextFieldAutoSize.CENTER;
			titleField.defaultTextFormat = new TextFormat(BFont.fontName, 20, 0xFFFFFF, true);
			titleField.filters = [new GlowFilter(0x00AAFF, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			titleField.x = this.width / 2;
			titleField.y = 30;
			titleField.text = "登录奖励";
			addChild(titleField);
				
			//消息
			var messageLabel:TextField = new TextField();
			messageLabel.selectable = false;
			messageLabel.width = 270;
			messageLabel.wordWrap = true;
			messageLabel.autoSize = TextFieldAutoSize.LEFT;
			messageLabel.defaultTextFormat = new TextFormat(BFont.fontName, 16, 0xFFFFFF, true);
			messageLabel.filters = [new GlowFilter(0x00AAFF, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			messageLabel.x = 70;
			messageLabel.y = 80;
			messageLabel.htmlText = "您已经连续<font color='#FF0000' size='18'><i> " + day + "  </i></font>天登录，为表彰您的勤劳工作给予以下奖励！";
			addChild(messageLabel);
			
			//物品框
			for (var i:int = 0; i < 3; i++)
			{
				var objectSlot:ObjectSlot = new ObjectSlot();
				objectSlot.x = 100 + i * 75;
				objectSlot.y = 140;
				addChild(objectSlot);
				if (awards != null && i < awards.length)
					objectSlot.addOjbect(awards[i]);
			}
			//消息
			var messageLabel2:TextField = new TextField();
			messageLabel2.selectable = false;
			messageLabel2.defaultTextFormat = new TextFormat(BFont.fontName, 16, 0xFFFFFF, true);
			messageLabel2.autoSize = TextFieldAutoSize.LEFT;
			messageLabel2.filters = [new GlowFilter(0x00AAFF, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			messageLabel2.x = 70;
			messageLabel2.y = 220;
			addChild(messageLabel2);
			
			//额外奖励
			if (awards != null && awards.length > 3)
			{
				messageLabel2.htmlText = "额外奖励";
				objectSlot = new ObjectSlot();
				objectSlot.x = 175;
				objectSlot.y = 250;
				objectSlot.addOjbect(awards[3]);
				addChild(objectSlot);
			}
			else
			{
				var nextSpecialDay:int = (int(day / 3) + 1);
				messageLabel2.htmlText = "连续登陆<font color='#FF0000' size='18'><i> " + (nextSpecialDay * 3) + "  </i></font>天后可获得：";
				objectSlot = new ObjectSlot();
				objectSlot.x = 175;
				objectSlot.y = 250;
				var obj:Obj = new Obj();
				if (nextSpecialDay == 1)
					obj.objectIndex = 300;
				else if (nextSpecialDay == 2)
					obj.objectIndex = 319;
				else
					obj.objectIndex = 504;
				obj.objectNum = 1;
				objectSlot.addOjbect(obj);
				addChild(objectSlot);
			}
			
			//关闭按钮
			var CloseButton:Class = ResourceHelper.getInstance().getClassByName("CloseButton1");
			closeButton = new BasicButton(CloseButton);
			closeButton.x = 235;
			closeButton.y = 330;
			addChild(closeButton);
			closeButton.addEventListener(MouseEvent.CLICK, onCloseClick);
		}
		
		public function onCloseClick(event:Event):void
		{
			close()
		}
		
	}
}